const app = getApp();
const db = wx.cloud.database()
Component({
  options: {
    addGlobalClass: true,
    name: ""
  },
  data: {
    movies: [],
    cardCur: 0,
    // 轮播图列表
    swiperList: [{
      id: 0,
      type: 'image',
      url: '/images/banner/monv.jpg'
    }, {
      id: 1,
      type: 'image',
      url: '/images/banner/tiananmen.jpg',
    }, {
      id: 2,
      type: 'image',
      url: '/images/banner/timg.jpg'
    }, {
      id: 3,
      type: 'image',
      url: '/images/banner/xingye.jpg',
    }, {
      id: 4,
      type: 'image',
      url: '/images/banner/yanhua.jpg'
    }],
    // 总榜单
    paiminglist: {
      dbName: 'movies',
      pageIndex: 1,
      pageSize: 10,
      filter: ".*",
      orderBy: 'rate',
      state: 'desc'
    },
    // 恐怖大片排行
    kongbulist: {
      dbName: 'movies',
      pageIndex: 1,
      pageSize: 10,
      filter: "恐怖",
      orderBy: 'rate',
      state: 'desc'
    },
    // 动作大片排行
    dongzuolist: {
      dbName: 'movies',
      pageIndex: 1,
      pageSize: 10,
      filter: "动作",
      orderBy: 'rate',
      state: 'desc'
    },
    // 科幻大片排行
    kehuanlist: {
      dbName: 'movies',
      pageIndex: 1,
      pageSize: 10,
      filter: "科幻",
      orderBy: 'rate',
      state: 'desc'
    },
  },
  // created: function () {
  //   this.getData();
  // },
  methods: {
    // cardSwiper
    cardSwiper(e) {
      this.setData({
        cardCur: e.detail.current
      })
    },
    // 绑定输入框的值
    updateValue(e) {
      let name = e.currentTarget.dataset.name;
      let nameMap = {}
      nameMap[name] = e.detail && e.detail.value ? e.detail.value : ".*"
      this.setData(nameMap)
    },
    // 监听输入框enter事件
    navigte(e) {
      wx.navigateTo({
        url: '/pages/leader/search/search?key=' + e.detail.value
      })
    }
  },
});
